package com.cwf.quality.common.enums;

public enum DataAnalyzerEnum {

    NULL_VALUE_ANALYZE("NULL_VALUE_ANALYZE",
            "com.cwf.quality.common.strategy.analyzer.NullValueDataAnalyzer",
            "SELECT COUNT(*) AS null_count FROM {table} WHERE {column} IS NULL"),

    UNIQUE_VALUE_ANALYZE("UNIQUE_VALUE_ANALYZE",
            "com.cwf.quality.common.strategy.analyzer.UniqueValueAnalyzer",
            "SELECT {column},COUNT(*) AS repeat_count FROM {table} GROUP BY {column} HAVING COUNT(*) > 1"),

    VALUE_RANGE_ANALYZE("VALUE_RANGE_ANALYZE",
            "com.cwf.quality.common.strategy.analyzer.ValueRangeDataAnalyzer",
            "SELECT MAX({column}) AS max,MIN({column}) AS min FROM {table}"),

    ROWS_ANALYZE("ROWS_ANALYZE",
            "com.cwf.quality.common.strategy.analyzer.RowsDataAnalyzer",
            "SELECT COUNT({column}) AS rows FROM {table}"),

    AVG_ANALYZE("AVG_ANALYZE",
            "com.cwf.quality.common.strategy.analyzer.AvgDataAnalyzer",
            "SELECT AVG({column}) AS avg FROM {table}"),

    MAX_LENGTH_ANALYZE("MAX_LENGTH_ANALYZE",
            "com.cwf.quality.common.strategy.analyzer.MaxLengthDataAnalyzer",
            "SELECT max(length(CAST({column} AS VARCHAR))) AS max_length FROM {table}"),

    VALUE_DISTRIBUTION_ANALYZE("VALUE_DISTRIBUTION_ANALYZE",
            "com.cwf.quality.common.strategy.analyzer.ValueDistributionDataAnalyzer",
            "SELECT {column}, COUNT({column}) AS count FROM {table} GROUP BY {column} ORDER BY COUNT({column}) DESC"),

    ;

    private String type;
    private String className;
    private String sql;

    DataAnalyzerEnum(String type, String className, String sql) {
        this.type = type;
        this.className = className;
        this.sql = sql;
    }

    public String getType() {
        return type;
    }

    public String getClassName() {
        return className;
    }

    public String getSql() {
        return sql;
    }
}
